home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 19 / 019.d81 / t.pps #43 < prev    next >
Text File  |  2022-08-26  |  2KB  |  132 lines

  1. ======================================
  2.   PEEKs, POKEs, and SYSes, Part 43
  3.  
  4.            by Jim Weiler
  5. ======================================
  6.  
  7.   Now, what nit-picking details do we
  8.  
  9. have to learn to make waveform, pulse
  10.  
  11. rate and volume behave?  Very few,
  12.  
  13. actually.  Since all voices work the
  14.  
  15. same, we'll only look at voice one.
  16.  
  17.             ----------
  18.  
  19.   WAVEFORM:
  20.  
  21.   As you already know, there are just
  22.  
  23. four waveforms for you to choose
  24.  
  25. from.  Each has a numeric value, as
  26.  
  27. outlined below:
  28.  
  29.           wave on    wave off
  30.           =======    ========
  31. TRIANGLE     17         16
  32. SAWTOOTH     33         32
  33. PULSE        65         64
  34. NOISE       129        128
  35.  
  36.   To turn a voice on, poke the wave
  37.  
  38. on value into SID+4.  As soon as you
  39.  
  40. do so, the voice will start playing
  41.  
  42. the waveform you selected.  The
  43.  
  44. volume envelope will proceed
  45.  
  46. through the attack, decay and sustain
  47.  
  48. portions.  Then, to turn the voice
  49.  
  50. off, poke the wave off value into
  51.  
  52. SID+4.  At that point, the release
  53.  
  54. portion of the envelope will be
  55.  
  56. activated.
  57.  
  58.   Here's a graphic representation of
  59.  
  60. what happens when you play a note:
  61.  
  62.     <-A-><D><--S----><-R->
  63.          .
  64.         . .
  65.        .   ...........
  66.       .               .
  67.      .               ^ .
  68.     .                !  .
  69.     ^                !   .
  70.   wave on        wave off
  71. POKE S+4,33     POKE S+4,32
  72.  
  73.              ----------
  74.  
  75.   PULSE RATE:
  76.  
  77.   As I said before, pulse rate is
  78.  
  79. only meaningful for a pulse waveform.
  80.  
  81. Pulse rate can be set from 0 to 4095.
  82.  
  83. A pulse rate of 2048 will produce a
  84.  
  85. perfect square wave (on half of the
  86.  
  87. time, off half of the time).
  88.  
  89.   You store the pulse rate as a
  90.  
  91. byte-and-a-half number in S+2 and
  92.  
  93. S+3.  The low byte goes in S+2, and
  94.  
  95. the high half-byte goes in S+3.
  96.  
  97.   It goes something like this in
  98.  
  99. BASIC:
  100.  
  101.   PU=2012
  102.   PH=INT(PU/256)
  103.   PL=PU-PH*256
  104.   POKE S+2, PL
  105.   POKE S+3, PEEK S+3 AND 240 OR PH
  106.  
  107.              ----------
  108.  
  109.   VOLUME:
  110.  
  111.   Nothing could be simpler than
  112.  
  113. volume:
  114.  
  115.   POKE S+24,VOL
  116.  
  117. Volume must have a value from 0 to 15.
  118.  
  119.              ----------
  120.  
  121.   That about covers the simpler
  122.  
  123. aspects of waveforms and voices.
  124.  
  125. Next month we'll cover pitch, and
  126.  
  127. then we'll be ready to make beautiful
  128.  
  129. music together with our C-64's.
  130.  
  131. ----------<end of article>---------
  132.